package svc

import (
	"context"
	"github.com/zeromicro/go-queue/kq"
	"github.com/zeromicro/go-zero/core/logx"
	"github.com/zeromicro/go-zero/core/service"
	"my-zero-tiktok/apps/api/internal/config"
)

type Consumer struct {
	ctx    context.Context
	svcCtx *ServiceContext
}

func NewConsumer(ctx context.Context, svcCtx *ServiceContext) *Consumer {
	return &Consumer{
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (c *Consumer) Consume(ctx context.Context, key, val string) error {
	logx.Infof("Consumer key :%s , val :%s", key, val)
	return nil
}

func Consumers(c config.Config, ctx context.Context, svcCtx *ServiceContext) []service.Service {
	return []service.Service{
		kq.MustNewQueue(c.Kafka, NewConsumer(ctx, svcCtx)),
	}

}
